#include "zygfont.h"

QMap<QString,QFont*>* ZygFont::FONT_MAP = new QMap<QString,QFont*>;

ZygFont::ZygFont(){

}

ZygFont::~ZygFont(){

}

//根据字号和字粗获取字体对象
QFont ZygFont::getFont(int pointSize, int weight){
    QString sizeString = QString("%1").arg(pointSize,3,10,QLatin1Char('0'));
    QString weightString = QString("%1").arg(weight,3,10,QLatin1Char('0'));
    QString mark = sizeString + weightString;

    if(ZygFont::FONT_MAP->contains(mark)){
        return *ZygFont::FONT_MAP->value(mark);
    }
    QFont* font = new QFont();
    font->setPointSize(pointSize);
    font->setWeight(weight);
    ZygFont::FONT_MAP->insert(mark,font);
    return *font;
}
